<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div
      id="demo"
      style="width: 100px; height: 100px; background-color: orange"
    ></div>

    <script>
      let cacheFn = function () {
        let t = new Date().getTime();
        cacheFn = function () {
          return t;
        };
        return cacheFn();
      };

      function addEvent(dom, type, handler) {
        if (dom.addEventListener) {
          dom.addEventListener(type, handler, false);
          addEvent = function (dom, type, handler) {
            dom.addEventListener(type, handler, false);
          };
        } else {
          dom.attachEvent("on" + type, handler);
          addEvent = function (dom, type, handler) {
            dom.attachEvent("on" + type, handler);
          };
        }
      }

      addEvent(demo, "click", function () {
        console.log(0);
      });
    </script>
  </body>
</html>
